import { commentModel } from "../Model/comModel.js"

export const addComDao = async (obj) => {
    return await commentModel.create(obj)
}
export const delComDao = async (id)=>{
    return await commentModel.findByIdAndDelete(id)
}
export const updateComDao = async(id,obj)=>{
    return await commentModel.findByIdAndUpdate(id,obj)
}

//获取所有评论
export const getComByPageDao = async (page,size)=>{
    const list = await commentModel.find().skip((page-1)*size).limit(size);
    const total = await commentModel.find().countDocuments();
    return {
        list,
        total
    } 
}

export const getComByIdsByPageDao = async (ids,page,size)=>{
    const list = await commentModel.find({ids}).skip((page-1)*size).limit(size);
    const total = await commentModel.find({ids}).countDocuments();
    return {
        list,
        total
    }
}